(function(Jml,ElementFactory){
	
	ElementFactory.addControl("grid",{
		template : "<div  ${prop} />",
		controlName : "igrid",
		_loadOption : function(){
			
			//得到子元素div
			var children = this.domTemplate.children();
			if(children.length){
				
				//通过 调用 Jml.ConfigLoader 里面的init（） 构建一个实例 <ccay.jml.js>
				var childConfig = new Ccay.Jml.ConfigLoader(null,this.page),
					plugins = [], columns = [],
					child, html, childOption;
				
				children.each(function(){
					child = $(this);
					
					//对迭代出来的子元素进行绑定，加载
					childConfig.load(child);
					
					//得到子元素div 里面的 data-option 属性值
					childOption = childConfig.option;
					
					//对子标签div 里面 data-role 属性的值进行判断
					if(!childConfig.role || childConfig.role == 'column')
					{
						if(html = child.html())
							childOption += (childOption ? ',' : '') + "content:'" + html.replaceAll('\n','') + "'";
						childOption && columns.push("{" +childOption + "}");
					}
					else
					{
						childOption && plugins.push("," + childOption);
					}
				});
				this.config.option += (this.config.option ?  "," : "") +
					"columns:[" +  columns.join(",\n") + "]" +  plugins.join("");
			}
		},
		_buildConfig:function(){
			this._loadOption();
			this.callParent("_buildConfig");
		}
	});
	
	/**
	 * repeat组件
	 */
	ElementFactory.addControl("repeat",{
		controlName : "repeat"
	});

})(Ccay.Jml,Ccay.Jml.ElementFactory);